package com.credit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.credit.common.ServerResponse;
import com.credit.pojo.company;
import com.credit.service.ICompanyService;
import com.credit.vo.CompanyVo;

/**
 * 客户业务模块
 * @author Administrator
 *
 */
@CrossOrigin(origins = "*", maxAge = 3600)//跨越请求配置
@RestController
@Controller
public class CompanyController {

	@Autowired
	private ICompanyService companyService;
	
	
	/**
	 * 查看客户业务模块代码
	 * @param c
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "selectCompany.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectCompany(CompanyVo c,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
			@RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
		
		
		return companyService.selectCompany(c, pageNum, pageSize);
	}
	
	
	
	
	/**
	 * 增加客户信息	
	 * @param c
	 * @return
	 */
	@RequestMapping(value = "addCompany.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse addCompany(company c) {

		return companyService.insertCompany(c);
	}
	
	
	/**
	 * 查看单个客户信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "selectOneCompany.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectCompany(Integer id) {

		return companyService.selectByPrimaryKey(id);
	}
	
	
	
	
	/**
	 * 修改客户信息
	 * @param c
	 * @return
	 */
	@RequestMapping(value = "upCompany.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse upCompany(company c) {
		
		
		return companyService.updateCompany(c);
	}
	
	
	
	
	
	/**
	 * 查看客户已提交业务模块代码
	 * @param c
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value = "selectAuditCompany.do", method = RequestMethod.POST)
	@ResponseBody
	public ServerResponse selectAuditCompany(CompanyVo c,@RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
			@RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
		
		
		return companyService.selectAuditCompany(c, pageNum, pageSize);
	}
	
}
